package com.intelligentcar.springboot.controller;

import com.intelligentcar.springboot.bean.Log;
import com.intelligentcar.springboot.service.LogServer;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Controller
public class LogController {
    @Autowired
    private LogServer logServerImpl;

    //查看日志表中的人员
    @RequestMapping("/user")
    @ResponseBody
    public Map user() {
        Map map = new HashMap();
        map.put("list", logServerImpl.user());
        return map;
    }
    //根据姓名查看日志表
    @RequestMapping("/select")
    @ResponseBody
    public Map select (@RequestBody Log log){
        Map map = new HashMap();
        map.put("total",logServerImpl.count1(log));
        map.put("list",logServerImpl.select(log,new RowBounds((log.getPage()-1)*log.getSize(),log.getSize())));
        return map;
    }
    //查看日志表
    @RequestMapping("/quanbu")
    @ResponseBody
    public Map quanbu (@RequestBody Log log){
        Map map = new HashMap();
        map.put("total",logServerImpl.count());
        map.put("list",logServerImpl.quanbu(new RowBounds((log.getPage()-1)*log.getSize(),log.getSize())));
        return map;
    }
}
